package com.jx.controller;

import com.baomidou.mybatisplus.extension.api.ApiResult;
import com.jx.common.utils.RequestUtils;
import com.jx.entity.CreditQueryLog;
import com.jx.service.UserCreditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 信用查询
 * @author Administrator
 */
@Controller
@RequestMapping("/credit")
public class CreditController {

    @Autowired
    private UserCreditService userCreditService;

    @GetMapping("/index")
    public String index(Model model){
        // model.addAttribute("message","thymeleaf");
        return "index";
    }

    /**
     * <p>
     * 信用查询
     * </p>
     */
    @GetMapping("/query")
    @ResponseBody
    public ApiResult<Object> queryCredit(CreditQueryLog query,  HttpServletRequest request) {
        query.setReqIp(RequestUtils.getClientIpAddress(request));
        return userCreditService.queryCredit(query);
    }


}
